package com.ironman.mes.plugin.tcl;

import cn.hutool.core.util.StrUtil;
import com.ironman.mes.plugin.common.XPlugin;
import lombok.extern.slf4j.Slf4j;
import net.dreamlu.iot.mqtt.core.client.MqttClient;
import org.noear.solon.core.AppContext;

import java.util.Arrays;
import java.util.List;

/**
 * description
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2024/11/9 14:38
 */
@Slf4j
public class XPluginImpl extends XPlugin {

    @Override
    public List<String> configYaml(String env) {
        return Arrays.asList("app.yml", StrUtil.format("app-mqtt{}.yml", StrUtil.isEmptyIfStr(env) ? "" : "-" + env));
    }

    @Override
    public Class<?> clazz() {
        return this.getClass();
    }

    @Override
    public void preStop(AppContext pluginContext) {
        MqttClient mqttClient = pluginContext.getBean(MqttClient.class);
        mqttClient.disconnect();
    }
}
